﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExChange.Model
{
    /// <summary>
    /// 返回值Json
    /// </summary>
    public class JsonData
    {
        /// <summary>
        /// 状态，通常情况下[0：失败、1：成功]
        /// </summary>
        public int status { get; set; }
        /// <summary>
        /// 消息，通常情况下[0：失败、1：成功]
        /// </summary>
        public string message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public object data { get; set; }
        /// <summary>
        /// 构造方法[status:0，message:失败]
        /// </summary>
        public JsonData()
        {
            this.status = 0;
            this.message = "失败";
        }
        /// <summary>
        /// 设置json状态为成功[status:1，message:成功]
        /// </summary>
        public void Success(string msg = "成功")
        {
            this.status = 1;
            this.message = msg;
        }
        /// <summary>
        /// 回调函数
        /// </summary>
        /// <param name="success">true为成功,false为失败</param>
        /// <returns></returns>
        public Messager Result(bool success)
        {
            return success == true ? new Messager() { msg = "操作成功", success = true } : new Messager() { msg = "操作失败", success = false };
        }
        public class Messager
        {
            public string msg { get; set; }
            public bool success { get; set; }

            public object data { get; set; }
        }
    }
  
}
